#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int N, V;
vector<pair<int, int> > vec[maxn];
int dp[maxn][maxn];
int main() {
  cin >> N >> V;
  for (int i = 1; i <= N; ++i) {
    int s, v, w;
    cin >> s;
    while (s--) {
      cin >> v >> w;
      vec[i].push_back({v, w});
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= V; ++j) {
      for (auto [volume, value] : vec[i]) {
        dp[i][j] = max(dp[i - 1][j], dp[i][j]);
        if (j >= volume)
          dp[i][j] = max(dp[i][j], dp[i - 1][j - volume] + value);
      }
    }
  }
  cout << dp[N][V] << endl;
}
